﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace NTQOnlineExam.Services.EntityFW.Entity
{
    public class Order
    {
        public Guid OrderId { get; set; }
        public int UserId { get; set; }
        public string Email { get; set; }
        public string BillingAddress { get; set; }
        public string BillingZipCode { get; set; }
        public string BillingPOBox { get; set; }
        public string BillingCity { get; set; }
        public string BillingCountry { get; set; }
        public DateTime CreationDate { get; set; }
        public string TransactionNo { get; set; }
        public decimal SubTotal { get; set; }
        public decimal? PaymentFee { get; set; }
        public decimal? PaymentFeeTax { get; set; }
        public int Status { get; set; }
        public int OrderUniqueId { get; set; }
        public int OrderType { get; set; }
        public IList<OrderDetail> OrderDetails { get; set; }
    }

    public class OrderMap : EntityTypeConfiguration<Order>
    {
        public OrderMap()
        {
            this.HasKey(t => t.OrderId);
            this.ToTable("Order");
            this.Property(t => t.OrderUniqueId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.HasMany(x => x.OrderDetails).WithRequired(x => x.Order).HasForeignKey(x => x.OrderId);
        }
    }
}



